package com.example.mobile0203zlw2021606130day0323;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    EditText yhm,mima,xiuyhm,xiumima;
    Button baocun;
    TextView baochun2,baochun3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        yhm=findViewById(R.id.yonghm);
       mima=findViewById(R.id.mima);
        xiuyhm=findViewById(R.id.yhxiugai);
        xiumima=findViewById(R.id.mimaxiugai);
        baocun=findViewById(R.id.button);
        baochun2=findViewById(R.id.baochun2);
        baochun3=findViewById(R.id.baochun3);
        baocun.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String x=yhm.getText().toString(); //也可以用yhm.getText().toString()
                String y=((EditText)findViewById(R.id.mima)).getText().toString();
//                baochun2.setText("用户名："+x+"      "+"密码："+y);
                String x_2=((EditText)findViewById(R.id.yhxiugai)).getText().toString();
                String y_2=((EditText)findViewById(R.id.mimaxiugai)).getText().toString();
                
                 if (x.equals("lihua")&&y.equals("123456")){
                     baochun3.setText("新用户："+x_2+"      "+"新密码："+y_2);
                }
               else if (x.equals(x_2)&&y.equals(y_2)){
                    Toast.makeText(MainActivity.this, "您输入的和之前一样，请重新输入！", Toast.LENGTH_SHORT).show();
                }
                else {
                     Toast.makeText(MainActivity.this, "您输入的用户或密码错误", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

}